package com.zlx.exchange.type.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zlx.exchange.domain.dto.TypeDTO;
import com.zlx.exchange.domain.entity.Type;
import com.zlx.exchange.domain.vo.TypeVO;
import com.zlx.exchange.type.dao.CategoryDao;
import com.zlx.exchange.type.dao.TypeDao;
import com.zlx.exchange.type.service.TypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * (Type)表服务实现类
 *
 * @author makejava
 * @since 2023-09-04 20:18:19
 */
@Transactional
@Service("typeService")
public class TypeServiceImpl implements TypeService {
    @Resource
    private TypeDao typeDao;

    @Resource
    private CategoryDao categoryDao;

    @Override
    public Object queryTypeByJson(TypeDTO typeDTO) {
        return new TypeVO(categoryDao.selectById(typeDTO.getCategoryId()), typeDao.selectBatchIds(typeDTO.getTypeList()));}


    @Override
    public Object queryCategory() {
        return categoryDao.selectList(null);
    }

    @Override
    public Object queryType(Integer categoryId) {
        return typeDao.selectList(new LambdaQueryWrapper<>(Type.class).eq(Type::getCategoryId, categoryId));
    }
}
